package com.sunny.services;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sunny.entity.User;
import com.sunny.repository.UserRepository;

/**
 * 
 * @author Catkin_nice
 *
 */
@Service
public class UserService {
	
	@Autowired
	private UserRepository userRepository;

	public void addUser(User user) {
		if (user != null) {
			User u = userRepository.save(user);
			System.out.println(u.getUserId());
		}	
	}
	
	public Collection<User> getUsers() {
		return userRepository.findAll();
	}

	public User getUser(Long userId) {
		return userRepository.findOne(userId);
	}

}
